package com.insurance.service.impl;

import com.insurance.service.ProducerService;



import org.springframework.beans.factory.annotation.Autowired;


import org.springframework.context.annotation.Bean;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessageCreator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.jms.*;


/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/11/03 13:55
 * Description:
 * Version: V1.0
 */
@Service
public class ProducerServiceImpl implements ProducerService {

    @Autowired(required = false)
    private JmsTemplate jmsTemplate;
   // @Resource(name = "queueDestination")
    private Destination destination;
    @Override
    public void sendMessage(final String message) {
        jmsTemplate.send(destination, new MessageCreator() {
            @Override
            public Message createMessage(Session session) throws JMSException {
                TextMessage textMessage = session.createTextMessage(message);
                System.out.println("发送消息：" + textMessage);
                return textMessage;
            }
        });

    }
}
